<?php

namespace Modules\Shop\Http\Resources;

use Modules\Core\Http\Resources\BaseResource;
use Modules\Shop\Models\Order;

class OrderResource extends BaseResource
{
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'order_id' => $this->order_id,
            'status' => $this->status,
            'status_label' => $this->getStatusLabel(),
            'origin' => $this->origin,
            'pre_total_fee' => $this->pre_total_fee,
            'total_fee' => $this->total_fee,
            'expired_at' => $this->expired_at,
            'payed_at' => $this->payed_at,
            'express_company' => $this->express_company,
            'express_no' => $this->express_no,
            'delivery_at' => $this->delivery_at,
            'receipt_at' => $this->receipt_at,
            'create_by' => $this->createBy->getName(),
            'payed_at' => $this->payed_at,
            'pay_driver' => $this->pay_driver,
            'pay_driver_label' => Order::$paydrivers[$this->pay_driver] ?? '',
            'created_at' => $this->created_at->format('Y-m-d H:i:s'),
            'updated_at' => $this->updated_at->format('Y-m-d H:i:s'),
        ];
    }
}
